<template>
	<view class="content">
		<view class="data-area">
			<view v-if="responseData" class="list-container">
				<view v-for="(item, index) in responseData" :key="index" class="list-item">
					<text class="item-title">{{item.title}}</text>
					<text class="item-answer">{{item.answer}}</text>
				</view>
			</view>
			<view v-else class="empty-state">
				<text>暂无数据</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				responseData: null
			}
		},
		onLoad() {
			this.getData()
		},
		methods: {
			getData() {
				this.responseData = null;
				
				uni.request({
					url: '/dev-api/list',
					method: 'GET',
					success: (res) => {
						console.log('完整响应:', res);
						if (res.statusCode == 200) {
							console.log('请求成功：', res.data);
							this.responseData = res.data;
						} else {
							console.error('请求失败，状态码:', res.statusCode);
						}
					},
					fail: (err) => {
						console.error('请求失败:', err);
					}
				});
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 20rpx;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.data-area {
		width: 100%;
		padding: 20rpx;
		box-sizing: border-box;
	}
	
	.loading {
		text-align: center;
		margin: 20rpx 0;
		color: #666;
	}
	
	.error {
		color: #ff0000;
		margin: 20rpx 0;
		padding: 10rpx;
		border: 1px solid #ff0000;
		border-radius: 4rpx;
	}
	
	.list-container {
		width: 100%;
	}

	.list-item {
		background-color: #ffffff;
		border-radius: 12rpx;
		padding: 24rpx;
		margin-bottom: 20rpx;
		box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
	}

	.item-title {
		font-size: 32rpx;
		color: #333;
		font-weight: 500;
		margin-bottom: 16rpx;
		display: block;
	}

	.item-answer {
		font-size: 28rpx;
		color: #666;
		display: block;
		padding-left: 20rpx;
		border-left: 4rpx solid #007AFF;
	}

	.empty-state {
		text-align: center;
		padding: 40rpx;
		color: #999;
		font-size: 28rpx;
	}
</style>
